Skip to content

Fix NoMethodError in CallBaseNode#modified_vars for anonymous rest#447

Merged
sinsoku merged 1 commit intomasterfrom
fix-anonymous-rest-modified-vars
May 4, 2026
Merged

Fix NoMethodError in CallBaseNode#modified_vars for anonymous rest#447
sinsoku merged 1 commit intomasterfrom
fix-anonymous-rest-modified-vars

Conversation

@sinsoku
Copy link
Copy Markdown
Collaborator

@sinsoku sinsoku commented May 3, 2026

Since ff8a516, anonymous rest arguments (bare *) are represented as
nil placeholders in @positional_args instead of DummyNilNode.
However, CallBaseNode#modified_vars iterates the positional args
array without skipping nil, raising NoMethodError when a call with
anonymous rest forwarding appears inside a branch (e.g.
if cond; bar(*); end) whose modified_vars is walked from
BranchNode#install0.

Use safe navigation so nil placeholders are skipped, matching how
each_subnode already guards against nil subnodes. Add a regression
case to scenario/args/anonymous_rest.rb.

Since ff8a516, anonymous rest arguments (bare `*`) are represented as
`nil` placeholders in `@positional_args` instead of `DummyNilNode`.
However, `CallBaseNode#modified_vars` iterates the positional args
array without skipping nil, raising NoMethodError when a call with
anonymous rest forwarding appears inside a branch (e.g.
`if cond; bar(*); end`) whose `modified_vars` is walked from
`BranchNode#install0`.

Use safe navigation so nil placeholders are skipped, matching how
`each_subnode` already guards against nil subnodes. Add a regression
case to scenario/args/anonymous_rest.rb.
Copy link
Copy Markdown
Member

@mame mame left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@sinsoku sinsoku merged commit c824bb8 into master May 4, 2026
12 checks passed
@sinsoku sinsoku deleted the fix-anonymous-rest-modified-vars branch May 4, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants